This element is a static repeat loop. It enables the designer to repeat several times the same piece of code, with a change in an index variable for each instance. It offers several ways of defining the index for the loop.
| Name | Value Type | Default Value | Description | Comment | V. |
|---|---|---|---|---|---|
|
index_name |
string |
index |
name of the variable used for the index in the loop. |
for nested repeats it is necessary to define different names for the index variable to avoid conflicts. |
1.7 |
|
count |
integer or a a mathematical formula using previously defined variables |
0 |
number of repeats. |
This is number of repeats for the code contained inside the REPEAT element. |
1.7 |
|
start |
integer or a mathematical formula using previously defined variables |
0 |
start value for the index published in the repeat loop. |
To be used with the count attributes. Defines the list of values for the index variable. |
1.7 |
|
index_list |
list of semi-column separated values (strings) |
empty |
List of values for the index variable. Also implies the number of repeats. |
This attribute overrides the start/count attributes. |
1.7 |
The following code:
<REPEAT count="2" start="1"> <ELEMENTA attribute_a="$index$"/> </REPEAT>
Is equivalent to:
<ELEMENTA attribute_a="1"/> <ELEMENTA attribute_a="2"/>
Similarly, using the index_list attribute instead, the following code:
<REPEAT index_list="A;B"> <ELEMENTA attribute_a="$index$"/> </REPEAT>
Is equivalent to:
<ELEMENTA attribute_a="A"/> <ELEMENTA attribute_a="B"/>
And you can modify the index_name attribute for nested loops, so that the following code:
<REPEAT count="2" start="1">
<REPEAT index_name="sub_index" count="2" start="1">
<ELEMENTA attribute_a="$index$-$sub_index$"/>
</REPEAT>
</REPEAT>
Is equivalent to:
<ELEMENTA attribute_a="1-1"/> <ELEMENTA attribute_a="1-2"/> <ELEMENTA attribute_a="2-1"/> <ELEMENTA attribute_a="2-2"/>
A formula can be used to compute the index and start values. For example the following code:
<VARIABLE id="a" value="1"> <VARIABLE id="b" value="0"> <REPEAT count="$a$*2" start="$b$+1"> <ELEMENTA attribute_a="$index$"/> </REPEAT>
Is equivalent to:
<ELEMENTA attribute_a="2"/> <ELEMENTA attribute_a="3"/>